#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
	int left = 0;
	int bgt = 0;
	int i = 0;
	int sum = 0;
	for (i = 0; i < 12; i++)
	{
		left += 300;
		scanf("%d", &bgt);
		left -= bgt;
		if (left < 0)
		{
			printf("-%d", i + 1);
			return 0;
		}
		if (left / 100 != 0)
		{
			sum += left / 100;
			left %= 100;
		}
	}
	printf("%d", sum * 120 + left);
	return 0;
}